package com.aerospace.serviceconsumer;

import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName MusicController
 * @Description TODO
 * @Author Aero
 * @Date 2019/12/14 18:55
 * @Version 1.0
 **/
@Controller
public class MusicController {
    @RequestMapping(value = "/getOne")
    public String getOne(HttpServletRequest request,HttpServletResponse response,String username){
        String a  = request.getParameter("foo");
        System.out.println(a);
        System.out.println(a);
        System.out.println(a);
        System.out.println(a);
        response.setHeader("Access-Control-Allow-Origin","*");

        System.out.println("ahahhahhahah");
        return "views/homePage.html";
    }

    @RequestMapping(value = "/postOne")
    @ResponseBody
    public String postOne(HttpServletRequest request,HttpServletResponse response){
        String a  = request.getParameter("foo");
        System.out.println(a);
        System.out.println(a);
        System.out.println(a);
        System.out.println(a);
        response.setHeader("Access-Control-Allow-Origin","*");

        System.out.println("ahahhahhahah");
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("status","success");
        return jsonObject.toString();
    }
}
